import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
    {
    title: '所属栏目',
    align:"center",
    dataIndex: 'categroyId_dictText'
   },
   {
    title: '标题',
    align:"center",
    dataIndex: 'title'
   },
   {
    title: '简短描述',
    align:"center",
    dataIndex: 'description'
   },
   {
    title: '图片',
    align:"center",
    dataIndex: 'img',
    customRender:render.renderAvatar,
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '更新日期',
    align:"center",
    sorter: true,
    dataIndex: 'updateTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "所属栏目",
      field: "categroyId",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "标题",
      field: "title",
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属栏目',
    field: 'categroyId',
    component: 'JTreeSelect',
    componentProps:{
        dict:"temple_category,name,id",
        pidValue:"0",
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属栏目!'},
          ];
     },
  },
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入标题!'},
          ];
     },
  },
  {
    label: '简短描述',
    field: 'description',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入简短描述!'},
          ];
     },
  },
  {
    label: '图片',
    field: 'img',
     component: 'JImageUpload',
     componentProps:{
      },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入图片!'},
          ];
     },
  },
  {
    label: '是否外部链接',
    field: 'isLink',
     component: 'JSwitch',
     componentProps:{
     },
  },
  {
    label: '链接地址',
    field: 'url',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
  {
    label: '内容',
    field: 'content',
    component: 'JCodeEditor', //TODO String后缀暂未添加
  },
];
